home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1998 June / SGI Freeware 1998 June.iso / dist / fw_ATxgopher.idb / usr / freeware / src / xgopher.1.3 / markList.c.z / markList.c
C/C++ Source or Header  |  1998-01-21  |  3KB  |  139 lines

  1. /* markList.c
  2.    routines to manage the bookmark list of gopher items. */
  3.  
  4.      /*---------------------------------------------------------------*/
  5.      /* Xgopher        version 1.3     08 April 1993                  */
  6.      /*                version 1.2     20 November 1992               */
  7.      /*                version 1.1     20 April 1992                  */
  8.      /*                version 1.0     04 March 1992                  */
  9.      /* X window system client for the University of Minnesota        */
  10.      /*                                Internet Gopher System.        */
  11.      /* Allan Tuchman, University of Illinois at Urbana-Champaign     */
  12.      /*                Computing and Communications Services Office   */
  13.      /* Copyright 1992, 1993 by                                       */
  14.      /*           the Board of Trustees of the University of Illinois */
  15.      /* Permission is granted to freely copy and redistribute this    */
  16.      /* software with the copyright notice intact.                    */
  17.      /*---------------------------------------------------------------*/
  18.  
  19.  
  20. #include <stdio.h>
  21.  
  22. #include "gopher.h"
  23. #include "itemList.h"
  24.  
  25. static gopherItemList    bookmarks = {NULL, NULL};
  26.  
  27. /* These routines are simply an interface to the gopher item list
  28.    management routines in itemList.c. */
  29.  
  30. /* bookmark list interface routines:
  31.  
  32.     markItem    Set a bookmark at an item.
  33.     unmarkItem    Remove a bookmarked item.
  34.     unmarkItemN    Remove the Nth bookmarked item.
  35.     unmarkAllItems    Remove all bookmarks
  36.     getMarkN     Return a ptr to Nth bookmarked item 
  37.     anyMarks    Report if the bookmark list is empty as T/F 
  38.     firstMark    Return a pointer to the head of the bookmark list
  39.     markListLength    return the number of items in the bookmark list
  40.  
  41. */
  42.  
  43.  
  44. /* markItem
  45.     Set a bookmark at an item. */
  46.  
  47. void
  48. markItem(gi)
  49. gopherItemP    gi;
  50. {
  51.     if (gi == NULL) return;
  52.  
  53.     if (! itemInList(&bookmarks, gi)) appendItem(&bookmarks, gi);
  54.  
  55.     return;
  56. }
  57.  
  58.  
  59. /* getMarkN 
  60.     return a pointer to the Nth item of the bookmark list
  61.     starting with number 0 */
  62.  
  63. gopherItemP
  64. getMarkN(n)
  65. int        n;
  66. {
  67.     return getItemN(&bookmarks, n);
  68. }
  69.  
  70.  
  71. /* unmarkItem
  72.     Remove a bookmarked item. */
  73.  
  74. void
  75. unmarkItem(gi)
  76. gopherItemP    gi;
  77. {
  78.     if (gi == NULL) return;
  79.  
  80.     removeItem(&bookmarks, gi);
  81. }
  82.  
  83.  
  84. /* unmarkItemN
  85.     Remove the Nth bookmarked item. */
  86.  
  87. void
  88. unmarkItemN(n)
  89. int    n;
  90. {
  91.     if (n < 0) return;
  92.  
  93.     removeItemN(&bookmarks, n);
  94. }
  95.  
  96.  
  97. /* unmarkAllItems
  98.     Remove all bookmarks */
  99.  
  100. void
  101. unmarkAllItems()
  102. {
  103.     gopherItemP    p;
  104.  
  105.     while ((p = bookmarks.first) != NULL) {
  106.         unmarkItem(p);
  107.     }
  108. }
  109.  
  110.  
  111. /* anyMarks
  112.     Report if the bookmark list is empty as T/F */
  113.  
  114. BOOLEAN
  115. anyMarks()
  116. {
  117.     return (bookmarks.first != NULL);
  118. }
  119.  
  120.  
  121. /* firstMark
  122.     Return a pointer to the head of the bookmark list */
  123.  
  124. gopherItemP
  125. firstMark()
  126. {
  127.     return bookmarks.first;
  128. }
  129.  
  130.  
  131. /* markListLength
  132.     return the number of items in the bookmark list */
  133.  
  134. int
  135. markListLength()
  136. {
  137.     return itemListLength(&bookmarks);
  138. }
  139.